/***************************************\
| Sets up right hand info bar and      	|
| maintains game timer.               	|
|					|
\***************************************/

int	sec;
WINDOW 	*timer_win;

/* prints updated time to timer window */
int disp_timer_easy ()
{
	/* Intervals of 30 seconds level up. */
	if(sec == 30 || sec == 60 || sec == 90 || sec == 120 || sec == 150)
	{
		wclear(timer_win);
		return 1;
	}
	box(timer_win, 0, 0);
	mvwprintw(timer_win, 1, 3, "Time elapsed:");
	mvwprintw(timer_win, 2, 3, "%02i seconds", sec);
	mvwprintw(timer_win, 4, 3, "Score:");
	mvwprintw(timer_win, 5, 3, "%i", score);
	mvwprintw(timer_win, 8, 3, "Difficulty: EASY");
	mvwprintw(timer_win, 10, 3, "Level: %i", Level);
	wrefresh(timer_win);
	return 0;
}

int disp_timer_medium ()
{
	/* Intervals of 30 seconds level up. */
	if(sec == 30 || sec == 60 || sec == 90 || sec == 120 || sec == 150)
	{
		wclear(timer_win);
		return 1;
	}
	box(timer_win, 0, 0);
	mvwprintw(timer_win, 1, 3, "Time elapsed:");
	mvwprintw(timer_win, 2, 3, "%02i seconds", sec);
	mvwprintw(timer_win, 4, 3, "Score:");
	mvwprintw(timer_win, 5, 3, "%i", score);
	mvwprintw(timer_win, 8, 3, "Difficulty: EASY");
	mvwprintw(timer_win, 10, 3, "Level: %i", Level);
	wrefresh(timer_win);
	return 0;
}

int disp_timer_hard ()
{
	/* Intervals of 30 seconds level up. */
	if(sec == 30 || sec == 60 || sec == 90 || sec == 120 || sec == 150)
	{
		wclear(timer_win);
		return 1;
	}
	box(timer_win, 0, 0);
	mvwprintw(timer_win, 1, 3, "Time elapsed:");
	mvwprintw(timer_win, 2, 3, "%02i seconds", sec);
	mvwprintw(timer_win, 4, 3, "Score:");
	mvwprintw(timer_win, 5, 3, "%i", score);
	mvwprintw(timer_win, 8, 3, "Difficulty: EASY");
	mvwprintw(timer_win, 10, 3, "Level: %i", Level);
	wrefresh(timer_win);
	return 0;
}

/* Counts up from 0. Gets called every second. */
void alarm_handler ( int sig )
{
	sec++;
	if(Difficulty == EASY)
	{
		score = score + 100;
		disp_timer_easy();
	}
	if(Difficulty == MEDIUM)
	{
		score = score + 200;
		disp_timer_medium();
	}
	if(Difficulty == HARD)
	{
		score = score + 300;
		disp_timer_hard();
	}
}

/* Ending instructions */
void finish(int sig)
{
  endwin();
  exit(0);
}
